
#ifndef _IO_MGR_H_
#define _IO_MGR_H_

#include "compiler.h"

//for battery power led
#define PWR_LED_4       24
#define PWR_LED_3       22
#define PWR_LED_2       14
#define PWR_LED_1       9
#define PWR_LED_4_PIO    PIOB
#define PWR_LED_3_PIO    PIOB
#define PWR_LED_2_PIO    PIOB
#define PWR_LED_1_PIO    PIOB

//for push-button
#define PUSH_BUTTON_PIO  PIOA
#define PUSH_BUTTON_PIO_IDX     28

//for hub-switch and usb-switch
#define HUB_SWITCH_PIO   PIOB
#define USB_SWITCH_PIO   PIOA
#define HUB_SWITCH_PIO_IDX  7
#define USB_SWITCH_PIO_IDX  27

//for hub-connect detect
#define HUB_CNCT_PIO            PIOA
#define HUB_CNCT_PIO_IDX        11

//for charge-switch detect
#define CHGE_SWITCH_PIO         PIOA
#define CHGE_SWITCH_PIO_IDX     7

//for NTC ctrl
#define NTC_ENABLE_PIO          PIOA
#define NTC_ENABLE_PIO_IDX      6

//for MFI IC reset
#define MFI_RESET_PIO           PIOA
#define MFI_RESET_PIO_IDX       14

//for devie-power enable    
#define DP_ENABLE_PIO           PIOB
#define DP_ENABLE_PIO_IDX       27

//for battery-power adc enable
#define BP_ADC_ENABLE_PIO       PIOB
#define BP_ADC_ENABLE_PIO_IDX   13

//for usb-vbus enable
#define USB_VBUS_PIO            PIOB
#define USB_VBUS_PIO_IDX        10

//for test-mode enable
#define TM_ENABLE_PIO           PIOB
#define TM_ENABLE_PIO_IDX       15

//for sd-card enable
#define SD_ENABLE_PIO           PIOA
#define SD_ENABLE_PIO_IDX       26
#define SD_CLK_PIO              PIOA
#define SD_CLK_PIO_IDX          19    
#define SD_CMD_PIO              PIOA
#define SD_CMD_PIO_IDX          20
#define SD_D0_PIO               PIOA
#define SD_D0_PIO_IDX           21    
#define SD_D1_PIO               PIOA
#define SD_D1_PIO_IDX           22
#define SD_D2_PIO               PIOA
#define SD_D2_PIO_IDX           23
#define SD_D3_PIO               PIOA
#define SD_D3_PIO_IDX           24

#define BURN_IN_TRIGGER_PIO             PIOB
#define BURN_IN_TRIGGER_PIO_IDX         15

#define BURN_IN_ENABLE_PIO             PIOB
#define BURN_IN_ENABLE_PIO_IDX         16

#define AUTH_CHIP_POWER_PIO            PIOB
#define AUTH_CHIP_POWER_PIO_IDX        26

#define LED_OFF         false
#define LED_ON          true

#define   LED_1         1
#define   LED_2         2
#define   LED_3         3
#define   LED_4         4

void io_init(void);
void led_set_status(uint8_t idx, bool led_state);
#define disable_vout_en()      PIO_reset_bit(DP_ENABLE_PIO, DP_ENABLE_PIO_IDX)
#define enable_vout_en()       PIO_set_bit(DP_ENABLE_PIO, DP_ENABLE_PIO_IDX)
void sdio_power_down(void);
void auth_chip_io_power_on(void);
void auth_chip_io_power_down(void);
void HSMCI_pin_config(void);

#define TURN_LED_ON(a, b)      PIO_reset_bit(a, b)
#define TURN_LED_OFF(a, b)     PIO_set_bit(a, b)


#endif
